<div id="timesheet-form">
<fieldset>
<% form_for :timesheet, :url =>{:action => 'report'} do |f|  %>

<p id="date-options">
  <label><%= l(:label_date)%>:</label><br />
  <%= radio_button_tag 'timesheet[period_type]', '1', @timesheet.period_type == Timesheet::ValidPeriodType[:default] %>
  <%= select_tag 'timesheet[period]', options_for_period_select((params[:timesheet].nil? ? nil : params[:timesheet][:period])),
                           :onfocus => '$("timesheet_period_type_1").checked = true;' %>
  <br /><br />

  <%= radio_button_tag 'timesheet[period_type]', '2', @timesheet.period_type  == Timesheet::ValidPeriodType[:free_period] %>
  <span onclick="$('timesheet_period_type_2').checked = true;">
    <label for="timesheet_date_from"><%= l(:timesheet_date_from_label)%>:</label><br />
    <%= f.text_field "date_from", :size => 10 %><%= calendar_for('timesheet_date_from') %><br />

    <label for="timesheet_date_to"><%= l(:timesheet_date_to_label)%>:</label><br />
    <%= f.text_field "date_to", :size => 10 %><%= calendar_for('timesheet_date_to') %><br /><br />
  </span>
</p>

<p>
  <label for="timesheet_sort"><%= l(:timesheet_group_by) %>:</label><br />
  <%= select_tag("timesheet[sort]", options_for_select(Timesheet::ValidSortOptions.invert, @timesheet.sort)) %>

</p>

<p>
  <label for="timesheet[projects][]"><%= l(:timesheet_project_label)%>:</label><br />
  <%= select_tag 'timesheet[projects][]',
    options_from_collection_for_select(@timesheet.allowed_projects, :id, :name, @timesheet.projects.collect(&:id)),
    { :multiple => true, :size => @list_size}
  %>
</p>


<p>
  <label for="timesheet[activities][]"><%= l(:timesheet_activities_label)%>:</label><br />
  <%= select_tag 'timesheet[activities][]',
    options_from_collection_for_select(@activities, :id, :name, @timesheet.activities),
    { :multiple => true, :size => @list_size}
  %>
</p>

<p>
  <label for="timesheet[users][]"><%= l(:timesheet_users_label)%>:</label><br />
  <%= select_tag 'timesheet[users][]',
    options_from_collection_for_select(User.find(:all, :conditions => ['status = ?', User::STATUS_ACTIVE]).sort { |a,b| a.to_s.downcase <=> b.to_s.downcase }, :id, :name, @timesheet.users),
    { :multiple => true, :size => @list_size}

           %>
</p>

<div class="clear"></div>
<%= submit_tag l(:button_apply),:class => 'button-small' -%>

<% end %>
</fieldset>
</div>

<% content_for(:header_tags) do %>
<style type="text/css">
#date-options { margin-left: 10px; }
#date-options input[type='radio'] { margin-left: -20px; }
</style>
<% end %>
